package main

import (
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	"gorm.io/gorm/logger"
	"gorm.io/gorm/schema"
	"log"
<<<<<<< HEAD
	"mxshop/mxshop_srvs/order_srv/model"
=======
	"mxshop/mxshop_srvs/inventory_srv/model"
>>>>>>> 82cae0cbbdc6a6f5b7f561f87fb1a8fc5bdaf7b1
	"os"
	"time"
)

func main() {
	// 参考 https://github.com/go-sql-driver/mysql#dsn-data-source-name 获取详情
<<<<<<< HEAD
	dsn := "root:123456@tcp(39.98.125.151:3306)/mxshop_order_srv?charset=utf8mb4&parseTime=True&loc=Local"
=======
	dsn := "root:123456@tcp(39.98.125.151:3306)/mxshop_inventory_srv?charset=utf8mb4&parseTime=True&loc=Local"
>>>>>>> 82cae0cbbdc6a6f5b7f561f87fb1a8fc5bdaf7b1

	newLogger := logger.New(
		log.New(os.Stdout, "\r\n", log.LstdFlags), // io writer（日志输出的目标，前缀和日志包含的内容——译者注）
		logger.Config{
			SlowThreshold:             time.Second, // 慢 SQL 阈值
			LogLevel:                  logger.Info, // 日志级别
			IgnoreRecordNotFoundError: true,        // 忽略ErrRecordNotFound（记录未找到）错误
			Colorful:                  true,        // 禁用彩色打印
		},
	)

	db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{
		NamingStrategy: schema.NamingStrategy{
			SingularTable: true,
		},
		Logger: newLogger})
	if err != nil {
		panic(err)
	}

<<<<<<< HEAD
	_ = db.AutoMigrate(&model.OrderGoods{}, &model.ShoppingCart{}, &model.OrderInfo{})
=======
	_ = db.AutoMigrate(&model.Inventory{})
>>>>>>> 82cae0cbbdc6a6f5b7f561f87fb1a8fc5bdaf7b1
}
